package com.lucy.wx.miniapp.controller;

import com.lucy.starter.domain.ResponseDTO;
import com.lucy.starter.loader.AuthService;
import com.lucy.wx.miniapp.config.WxMiniAppConfig;
import com.lucy.wx.miniapp.core.MiniAppOpen;
import com.lucy.wx.miniapp.core.MiniAppToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author kindear
 * 微信小程序基础应用
 */
@RestController
@RequestMapping("wx/mini")
@Api(tags = "微信小程序-核心服务")
@AllArgsConstructor
public class MiniAppCoreController {
    MiniAppToken miniAppToken;

    MiniAppOpen miniAppOpen;


    AuthService authService;

    WxMiniAppConfig miniAppConfig;

    @GetMapping("token")
    @ApiOperation(value = "TOKEN查询",notes = "")
    public ResponseDTO<Object> tokenGet(){
        return ResponseDTO.succData(
                miniAppToken.get()
        );
    }

    @GetMapping("openid")
    @ApiOperation(value = "获取OpenId")
    public ResponseDTO<Object> openIdGet(@RequestParam("code") String code){
        return ResponseDTO.succData(
                miniAppOpen.getOpenId(code)
        );
    }

}
